<template>
  <div class="url-table">
    <el-form ref='searchForm' :inline="true" :model="searchForm" class="demo-form-inline">
      <el-form-item label="页面名称：">
        <el-input
          v-model="searchForm.pageName"
          placeholder="请输入页面名称"
        ></el-input>
      </el-form-item>
      <el-form-item label="配置人员：">
        <el-input
          v-model="searchForm.userName"
          placeholder="请输入配置人员"
        ></el-input>
      </el-form-item>
      <el-form-item label="页面url:">
        <el-input
          v-model="searchForm.url"
          placeholder="请输入页面url"
        ></el-input>
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          @click="onSearchPage"
          icon="el-icon-search"
          size="small"
          >查询</el-button
        >
        <el-button
          @click="resetForm('searchForm')"
          icon="el-icon-refresh"
          type="info"
          size="small"
          >重置</el-button
        >
        <el-button
          @click="exportExcel"
          icon="el-icon-download"
          type="warning"
          size="small"
          >导出</el-button
        >
        <el-button
          @click="addPage"
          icon="el-icon-download"
          type="primary"
          size="small"
          >添加页面</el-button
        >
      </el-form-item>
    </el-form>
    <!-- 表格 -->
    <el-tabs type="card">
      <el-tab-pane label="语音播报"></el-tab-pane>
      <!-- <el-tab-pane label="大字编辑"></el-tab-pane> -->
    </el-tabs>
    <el-table :data="tableData" style="width: 100%">
      <el-table-column fixed type="index" label="序号" width="150">
      </el-table-column>
      <el-table-column prop="pageName" label="页面名称" width="120">
      </el-table-column>
      <el-table-column prop="isHaveConfig" label="状态" width="120">
      </el-table-column>
      <el-table-column prop="createdName" label="配置人员" width="120">
      </el-table-column>
      <el-table-column prop="businessLine" label="业务线"> </el-table-column>
      <el-table-column prop="testResult" label="测试结果"> </el-table-column>
      <el-table-column prop="qrcode" label="二维码">
        <template slot-scope="scope">
          <qr-code :id="'QrCode'" :width="'108'" :height="'108'" :text="tableData[scope.$index].url"></qr-code>
        </template>
      </el-table-column>
      <el-table-column fixed="right" label="操作">
        <template slot-scope="scope">
          <el-button @click="handleClick(scope.row)" type="text" size="small"
            >去配置</el-button
          >
          <!-- <el-button type="text" size="small" @click="dialogFormVisible = true"
            >编辑</el-button
          > -->
        </template>
      </el-table-column>
    </el-table>
    <el-dialog title="收货地址" :visible.sync="dialogFormVisible">
      <el-form :model="form">
        <el-form-item label="活动名称">
          <el-input v-model="form.name" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="活动区域">
          <el-select v-model="form.region" placeholder="请选择活动区域">
            <el-option label="区域一" value="shanghai"></el-option>
            <el-option label="区域二" value="beijing"></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="dialogFormVisible = false"
          >确 定</el-button
        >
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { configInfoApi } from '@/api/system/agingDesign'
import qrCode from './qrCode.vue'
// import qrCode from './qrCode.vue'
export default {
  components: {
    qrCode
  },
  data () {
    return {
      dialogFormVisible: false,
      searchForm: {
        pageName: '',
        createdName: '',
        url: ''
      },
      tableData: [],
      form: {
        name: '',
        region: '',
        date1: '',
        date2: '',
        delivery: false,
        type: [],
        resource: '',
        desc: ''
      },
      // formLabelWidth: '500px'
    }
  },
  created () {
    this.getConfigInfo()
  },
  methods: {
    getConfigInfo () {
      const params = {
        agingDesignType: "0",
        appId: this.$route.query.appId,
        pageNo: '',
        pageSize: 10,
        pageName: this.searchForm.pageName,
        createdName: this.searchForm.createdName,
        url: this.searchForm.url
      }
      configInfoApi(params).then((res) => {
        console.log(res);
        this.tableData = res.rows
      })
    },
    onSearchPage () {
     this.getConfigInfo()
    },
    resetForm (formName) {
      this.searchForm = {
        pageName: '',
        createdName: '',
        url: ''
      }
      this.getConfigInfo()
    },
    exportExcel () {
      console.log('导出');
    },
    handleClick (row) {
      this.$router.push({
        path: '/system/preview/',
        query: {
          url: row.url,
          appId: row.appId
        }
      })
      console.log(row);
    },
    addPage(){

    }
  }
}
</script>

<style scoped>
.url-table {
  padding: 20px;
}
::v-deep .el-tabs__content {
  padding: 0;
}
</style>
